<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<%@ page import="com.niagara.security.auth.AuthenticationProvider"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>后台管理登录</title>
	<%@ include file="/common/meta.jsp"%>
	
	<link href="${ctx}/css/default.css" type="text/css" rel="stylesheet" />
	<script src="${ctx}/js/jquery.js" type="text/javascript"></script>
	<%-- <script src="${ctx}/js/validate/jquery.validate.js" type="text/javascript"></script>
	<script src="${ctx}/js/validate/messages_cn.js" type="text/javascript"></script>
  	<script>
  		$(document).ready(function(){
    		$("#loginForm").validate();
    	});
  	</script>--%>
  	<script type="text/javascript">

		function refreshCaptcha(){
				$('#captchaImg').html('<img src="${ctx}/jcaptcha.jpg?'+Math.round(Math.random()*100000)+'"/>');
		}
	</script>
</head>
<body>

	<h2>后台管理登录</h2>
	<%	String errorKey=(String)session.getAttribute(AuthenticationProvider.SESSION_KEY_ERROR);
		if(AuthenticationProvider.ERROR_KEY_PASSWORD_ERROR.equals(errorKey)){
	%>
			<span style="color:red"> 密码错误，请重试.</span>
	<%
		}else if(AuthenticationProvider.ERROR_KEY_NO_USER.equals(errorKey)){
	%>
			<span style="color:red">用户不存在.</span>
	<%		
		}else if(AuthenticationProvider.ERROR_KEY_CAPTCHA_ERROR.equals(errorKey)){
	%>
			<span style="color:red">验证码错误，请重试.</span>
	<%	
		}else if(AuthenticationProvider.ERROR_KEY_AUTHENTICATE_EXCEPTION.equals(errorKey)){
	%>
			<span style="color:red">登录错误，请重试.</span>
	<%		
		}
	%>
	<form id="loginForm" action="${ctx}/niagara_security_login_check" method="post">
		<table class="inputView">
			<tr>
				<td align="right">用户名:</td>
				<td>
					<input type='text' name='niagara_security_params_login_id' class="required" style="width:175px;"/>
				</td>
			</tr>
			<tr>
				<td align="right">密&nbsp;&nbsp;&nbsp;&nbsp;码:</td>
				<td><input type='password' name='niagara_security_params_password' class="required" style="width:175px;"/></td>
			</tr>
			<tr>
				<td align="right">验证码:</td>
				<td><input type='text' name='niagara_security_params_captcha' class="required" style="width:175px;"/></td>
			</tr>
			<tr>
				<td colspan="2"><span id="captchaImg" ><img src="${ctx}/jcaptcha.jpg" /></span><a href="javascript:refreshCaptcha()">看不清楚换一张</a></td>
			</tr>
			<!-- 
			<tr>
				<td>
					<input type="checkbox" name="_spring_security_remember_me" />
				</td>
				<td>两周内记住我</td>
			</tr> -->
			<tr>
				<td ><input value="登录" type="submit" /></td>
				<td ><input value="重置" type="reset" />
				</td>
			</tr>
		</table>
	</form>
	<p>（管理员<b>admin/a</b>）</p>
</body>
</html>